﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using GPSTracker.Helper;
using System.Text;

namespace GPSTracker.Views.DAL
{
    public class DispatchEntryDAL
    {
        public DataTable FillArea()
        {
            var sb = new StringBuilder();
            var dt = new DataTable();

            var strSQL = "SELECT AreaID,AreaName FROM dbo.VW_GetArea";
            var da = new SqlDataAdapter(strSQL, CommonFx.GetSqlCon());
            da.Fill(dt);

            return dt;
        }

        public DataTable FillTempo(string strBranchID,string strWarehouseID, string strLoginID)
        {
            var sb = new StringBuilder();
            var dt = new DataTable();

            SqlCommand cmd = new SqlCommand("SP_FillTempo", CommonFx.GetSqlCon());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandTimeout = 300000000;

            cmd.Parameters.AddWithValue("@pBranchID", strBranchID);
            cmd.Parameters.AddWithValue("@pWhouseID", strWarehouseID);
            cmd.Parameters.AddWithValue("@pLoginID", strLoginID);

            //var strSQL = "SELECT TempoID,TempoNo FROM dbo.VW_GetTempoMaster WHERE ISNULL(IsActive,'NO') = 'YES'";
            var da = new SqlDataAdapter(cmd);            
            da.Fill(dt);

            return dt;
        }

        public DataTable FillDeliveryBoy(string strBranchID, string strWarehouseID, string strLoginID)
        {
            var sb = new StringBuilder();
            var dt = new DataTable();

            SqlCommand cmd = new SqlCommand("SP_FillEmp", CommonFx.GetSqlCon());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandTimeout = 300000000;

            cmd.Parameters.AddWithValue("@pBranchID", strBranchID);
            cmd.Parameters.AddWithValue("@pWhouseID", strWarehouseID);
            cmd.Parameters.AddWithValue("@pLoginID", strLoginID);
            cmd.Parameters.AddWithValue("@pDesignation", "Delivery Boy");
            //var strSQL = "SELECT LoginID,EmpName FROM VW_EmployeeMaster WHERE ISNULL(IsActive,0) = 1";
            var da = new SqlDataAdapter(cmd); 
            da.Fill(dt);

            return dt;
        }
    }
}
